﻿using System;
using System.Web.UI;
namespace Common.Web.Pages
{
    /// <summary>
    /// 页面层(表示层)基类,所有页面继承该页面
    /// </summary>
    public class PageBase : System.Web.UI.Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.Error += new System.EventHandler(PageBase_Error);  //向页面注册onerror方法
            IsOnLoad();
        }

        public void IsOnLoad()
        {
            Cookie cookie = new Cookie();
            string LoginUserId = cookie.GetCookie("LoginUserId");
            string usertype = cookie.GetCookie("LoginUserType");
            cookie.SetCookie("LoginUserType", usertype, 1);
            if (!string.IsNullOrEmpty(LoginUserId))
            {
                cookie.SetCookie("LoginUserId", LoginUserId, 1);
            }
            else
            {
                Response.Redirect("ToLong.aspx");
            }
        }

        /// <summary>
        /// 错误处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void PageBase_Error(object sender, System.EventArgs e)
        {
            string s = this.Page.ToString() + "页面崩溃";
            s.Debug();
            //     Response.Redirect("Default.aspx");
        }
    }
}

